﻿// Singleton.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include <iostream>
#include "Singleton.h"

class MyClass
{
public:
	typedef std::shared_ptr<MyClass> Ptr;
	MyClass();
	~MyClass();
	void test() { printf("MyClass::test()\n"); }

private:

};

MyClass::MyClass()
{
}

MyClass::~MyClass()
{
}
using App_ConnectCounter = Singleton<MyClass>;

int test_Singleton1()
{
	{
		MyClass::Ptr  pMyClass(new MyClass());
		pMyClass->test();
	}
	
	MyClass& s1 = Singleton<MyClass>::Instance();
	MyClass& s2 = Singleton<MyClass>::Instance();

	s1.test();

	if (&s1 == &s2)
		std::cout << "ok" << std::endl;
	else
		std::cout << "no" << std::endl;
	return 0;
}

int main()
{
	test_Singleton1();
    std::cout << "Hello World!\n";
}
